package com.oocl.o2o.client.listener;

import java.util.List;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.web.context.support.WebApplicationContextUtils;

import com.oocl.o2o.client.db.FoodTypeDB;
import com.oocl.o2o.client.entity.FoodType;
import com.oocl.o2o.client.service.FoodTypeService;
import com.oocl.o2o.client.service.impl.FoodTypeServiceImpl;

/**
 * Application Lifecycle Listener implementation class FoodTypeListener
 *
 */
public class FoodTypeListener implements ServletContextListener  {

	
    /**
     * Default constructor. 
     */
    public FoodTypeListener() {
        // TODO Auto-generated constructor stub
    }

	/**
     * 系统启动 的时候 加载系统已经存在了的 食品类型信息
     */
    public void contextInitialized(ServletContextEvent sce) {
    	FoodTypeDB foodTypeDB = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()).getBean(FoodTypeDB.class);
    	foodTypeDB.loadFoodTypes();
    	sce.getServletContext().setAttribute("AllFoodTypes", FoodTypeDB.getFoodTypes());
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
        // TODO Auto-generated method stub
    }
	
}
